﻿@using viBook.Common
@using viBook.Helpers
@using viBook.Models
@model User
@{
    ViewBag.Title = "Profiles";
    Layout = "~/Views/Shared/_UserLayout.cshtml";
    var locality = (String.IsNullOrEmpty(Model.Location)) ? "Secret" : Model.Location;
}
<div class="profile-actions">
</div>
<div class="full">
    <div class="profile vcard profile-freeagent group">
        <img alt="@Model.DisplayName avatar" class="photo" src="@Model.AvatarUrl" />
        <h1>
            <span class="fn edit">@Model.DisplayName</span>
        </h1>
        <ul class="profile-details">
            <li><span class="locality">@locality</span></li>
        </ul>
        @if (ViewBag.IsOwner)
        {
            <a href="@Url.Action("details", "account")" class="action edit-account"><span>Edit Your
                                                                                        Account</span></a>
        }
        @if (!ViewBag.IsOwner)
        {
            <ul class="admin">
            <li id="flag-section" class="flag" data-bind="visible: isBlocked()==false"><a href="#" data-bind="click: report"><span data-bind="visible: isReported()==false">Report this user</span></a>
                <span data-bind="visible: isReported">Flaged</span>
            </li>
            <li id="blocked-section" class="block" data-bind="visible: isBlocked">
                <a href="#"><span>Blocked</span></a>
            </li>
            </ul>
        }
    </div>
</div>
<div id="main">
    <ul class="tabs">
        <li class="active"><a href="@Url.Action("Index", "Account")">Uploaded Books <span
            class="meta">(@Model.UploadedBooks.Count())</span></a> </li>
    @if (ViewBag.IsOwner)
    {
        <li><a href="@Url.Action("Activities", "Account")">Recent activities</a> </li>
    }
    @if (!ViewBag.IsOwner)
    {
        <li><a href="@Url.Action("Activities", "Account", new { id = Model.Id })">Recent activities</a> </li>
    }
    </ul>
    <ol class="dribbbles group">
        <div data-bind='template: { name: "book-template", foreach: uploadedBooks }' id="uploaded-book">
        </div>
    </ol>
    @*Pager*@
    <div class="page">
        <div class="pagination">
            <a class="next_page" rel="next" id="prev" data-bind="visible: isShowPrevBtn,click: fetchPreviousCommentPage">
                Previous</a> (Page <span data-bind="text: viewmodel.bookPageNo()"></span>of
            <span data-bind="text: viewmodel.totalBookPage()"></span>) <a class="next_page" rel="next"
                id="next" data-bind="visible: isShowNextBtn,click: fetchNextCommentPage">Next</a>
        </div>
    </div>
</div>
<!-- /main -->
<div id="secondary">
    <h3>
        About <span class="meta">@Model.DisplayName</span>
    </h3>
    <div class="profile-data">
        <p class="copy">
            @Model.Biography
        </p>
    </div>
    @if (ViewBag.IsOwner)
    {
        <h3 class="tab">
            <a href="#">New Book <span class="meta"></span></a>
        </h3>
        <ol class="buckets group">
            <li class="group">@Html.ActionLink("Upload a new book", "Create", "Books", null, new { @class = "action edit-account" })</li>
        </ol>
    }
    <h3 class="tab">
    @if (ViewBag.IsOwner)
    {
        <a href="@Url.Action("Activities", "Account")">Recent <span class="meta">Activities</span> </a>        
    }
    @if (!ViewBag.IsOwner)
    {
        <a href="@Url.Action("Activities", "Account", new { id = Model.Id })">Recent <span class="meta">Activities</span> </a>        
    }
    </h3>
    <ol class="activity-mini">
        @foreach (var item in Model.Activities.Take(Constant.MaximumActivitiesToPaging))
        {
            <text>
            <li>
                <p>@(new HtmlString(item.Description))</p>
                <em class="time">@Helpers.ConvertDateToString(item.CreatedDate)</em> </li>
            </text>
        }
        <!--<li class="like"><strong>Liked</strong> a <a href="/shots/226835-The-Cocktail-App-in-App-Store-now-#comment-580454">
                                                      comment</a> by <a href="/NicholasLEby" class="url" rel="contact">Nicholas L. Eby</a>
            <em class="time">about 11 hours ago</em> </li>
        <li class="like"><strong>Liked</strong> <a href="/shots/197296-Edit">Edit</a> <em
                                                                                          class="time">about 12 hours ago</em> </li>-->
    </ol>
</div>
@Html.Partial("~/Views/Home/BookControlTemplate.cshtml")
@Html.Partial("IndexJS")
